package com.it.lock.service.impl;

import com.it.lock.config.MyRedissonConfig;
import com.it.lock.service.RedissonLockService;
import lombok.extern.slf4j.Slf4j;
import org.redisson.Redisson;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class RedissonLockServiceImpl implements RedissonLockService {


    @Autowired
    RedissonClient redisson;

    @Override
    public void getRedisLock() {
        RLock lock = redisson.getLock("my-lock");
        lock.lock();
        log.info("执行业务中");
        lock.unlock();
        log.info("锁释放成功");




    }
}
